import { Body, Get, Post, Query } from '@nestjs/common';
import Controller from 'src/admin/decorator/controller.decorator';
import { successReturn } from 'src/utils';
import { VoteService } from './vote.service';

@Controller('vote')
export class VoteController {
    constructor(private service:VoteService){}
    @Get()
    async votePage(@Query() query) {
        let rows = await this.service.getPageById(query.lastKey, query.pageSize)
        return successReturn(rows)
    }

    @Get('detail')
    async detail(@Query() query) {
        let rows = await this.service.getVoteById(query.id)
        return successReturn(rows)
    }

    @Post('vote')
    async vote(@Body() params) {
        let optionId = params.optionId
        let result = await this.service.vote(optionId)

        return result
    }
}
